package com.mg.game;

import android.graphics.Canvas;

import com.mg.framework.kernel.Assets;
import com.mg.framework.kernel.Screen;

public class GameScreen extends Screen {

	private GameBackground gBg = null;
	private Cloud[] clouds = null;
	private int cloudNumber = 8;
	private GameWorld gw = null;
	private Box[][] boxs = null;
	private Box box = null;

	public GameScreen(int width, int height) {
		super(width, height);
		this.gBg = (GameBackground) this.addActor("gameBackground",
				new GameBackground(this, Assets.gBg));
		this.clouds = new Cloud[cloudNumber];
		for (int i = 0; i < this.clouds.length; i++) {
			this.clouds[i] = new Cloud(this, Assets.clouds[i / 2]);
		}
		this.gw = new GameWorld(this);
		this.boxs = gw.createBoxs();
		this.box = gw.createBox(0, this.getHeight() - 10, this.getWidth(), 10,
				false, 0);
	}

	@Override
	public void gameUpdate() {
		this.gBg.gameUpdate();
		for (int i = 0; i < this.clouds.length; i++) {
			this.clouds[i].gameUpdate();
		}
		this.gw.step();
		for (int i = 0; i < 1; i++) {
			for (int j = 0; j < 2; j++) {
				this.boxs[i][j].gameUpdate();
			}
		}
		this.box.gameUpdate();
	}

	@Override
	public void screenUpdate(Canvas canvas) {
		this.gBg.screenUpdate(canvas);
		for (int i = 0; i < this.clouds.length; i++) {
			this.clouds[i].screenUpdate(canvas);
		}
		for (int i = 0; i < 1; i++) {
			for (int j = 0; j < 2; j++) {
				this.boxs[i][j].screenUpdate(canvas);
			}
		}
		this.box.screenUpdate(canvas);
	}

}
